package com.zhiwen.listener;

import org.springframework.jms.listener.SessionAwareMessageListener;

import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;

/**
 * @Auther: wuzhiwen
 * @Date: 2019/2/13 10:13
 * @Description:
 */
public class ConsumerSessionAwareMessageListener implements SessionAwareMessageListener<TextMessage> {

    private Destination destination;

    @Override
    public void onMessage(TextMessage textMessage, Session session) throws JMSException {
        System.out.println("收到一条消息");
        System.out.println("消息内容:" + textMessage.getText());
        MessageProducer producer = session.createProducer(destination);
        TextMessage message = session.createTextMessage("ConsumerSessionAwareMessageListener....");
        producer.send(message);
    }

    public Destination getDestination() {
        return destination;
    }

    public void setDestination(Destination destination) {
        this.destination = destination;
    }
}
